package com.example.controller;

import com.example.service.FileService;
import com.example.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Api(tags = "文件上传")
public class FileController {
    @Autowired
    private FileService fileService;


    @Value("${filepath}")
    private String filepath;
    /**
     * 获取日志记录器
     */
    private Logger logger = LoggerFactory.getLogger(FileController.class);

    @ApiOperation(value = "文件上传", notes = "文件上传")
    @PostMapping("/singlefile")
    public Object singleFileUpload(MultipartFile file) {
        logger.debug("------------" + file + "-------------");
        return fileService.uploadFile(file, filepath);
    }
}
